import {AbstractControl, Validators as ngValidators} from '@angular/forms';
import {ValidatorFn} from '@angular/forms/src/directives/validators';

export class Validators {

  public required = ngValidators.required;
  public min = ngValidators.min;
  public max = ngValidators.max;
  public maxLength = ngValidators.maxLength;
  public minLength = ngValidators.minLength;
  public requiredTrue = ngValidators.requiredTrue;
  public email = ngValidators.email;
  public pattern = ngValidators.pattern;

  public equals = function (compareTo: AbstractControl): ValidatorFn {
    return (control: AbstractControl): { [key: string]: any } => {
      if (control.value !== compareTo.value) {
        return {'equals': {'controlValue': control.value, 'compareToValue': compareTo.value}};
      }
      return null;
    };
  };

}
